import React from 'react'
import {
    Form,
    Button,
    message,
    Switch,
    Card,
    Icon,
    Input,
    Table,
    Popconfirm,
    Divider,
    Spin,
} from 'antd'
import { observer, inject } from 'mobx-react'
import _ from 'lodash'
import util from '../../../common/util'
import Tip from "../../common/tip"

const FormItem = Form.Item

@inject("store")
@observer
class List extends React.Component {
    constructor() {
        super()
    }
    componentDidMount = () => {
        this.props.store.actions.getExhibition(this.props.stat)
    }
    componentWillReceiveProps(nextProps) {
        if(nextProps.stat!=this.props.stat)
            this.props.store.actions.getExhibition(nextProps.stat)
    }
    render() {
        let {store,stat} = this.props
        let data = store.list
        const actions = store.actions
        const columns = [{
            title: '展览名称',
            dataIndex: 'expoName',
            render: (text,record) => <a href={`/exhibition/detail?id=${record.id}`} target='_blank'>{text}</a>,
        }, {
            title: '展览时间',
            dataIndex: 'time',
            key:'time',
        }, {
            title: '领域',
            dataIndex: 'expoScope',
            key: 'expoScope',
        },
        ];
        stat==1&&columns.push({
            title: '操作',
            key: 'action',
            width: 360,
            render: (text, record) => (
                <span>
                  <a href={`/api/expo/downloadVerify?expoId=${record.id}`}>查看验证码</a>
                  <Divider type="vertical" />
                    <a href={`/console/exhibition/exhibitorManage/${record.id}`} >参展商管理</a>
                  <Divider type="vertical" />
                  <a href={`/console/exhibition/edit/${record.id}`} >修改信息</a>
                  <Divider type="vertical" />
                    <Popconfirm
                        title="确认取消展览吗?"
                        onConfirm={() => actions.delExpo(record.id)}
                    >
                    <a>取消展览</a>
                  </Popconfirm>
                </span>
            ),
        })
        return (
            <Spin spinning={store.loading}>
                <Tip title={stat==1?"正在进行展览":stat==-1?"已结束展览":"已登录展览"}/>
                <Table
                    columns={columns}
                    dataSource={data.slice()}
                />
            </Spin>
        )
    }
}

export default List

